/*
 * Copyright (c) 2011, INRIA
 * All rights reserved.
 */
package fr.inria.edelweiss.sparql.soap;

import fr.inria.edelweiss.sparql.DriverParametersPanel;
import java.util.Observable;

/**
 *
 * @author edemairy
 */
public final class SparqlSoapEndPointDriverParametersPanel extends DriverParametersPanel<SparqlSoapEndPointDriverParameters> {

	private final SparqlSoapEndPointDriverParameters driverParameters;

	public SparqlSoapEndPointDriverParametersPanel(SparqlSoapEndPointDriverParameters newDriverParameters) {
		super();
		initComponents();
		driverParameters = newDriverParameters;
		reset();
	}

	/**
	 * This method is called from within the constructor to initialize the
	 * form. WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {

                urlLabel = new javax.swing.JLabel();
                urlTextField = new javax.swing.JTextField();

                urlLabel.setText(org.openide.util.NbBundle.getMessage(SparqlSoapEndPointDriverParametersPanel.class, "SparqlSoapEndPointDriverParametersPanel.urlLabel.text")); // NOI18N

                urlTextField.setText(org.openide.util.NbBundle.getMessage(SparqlSoapEndPointDriverParametersPanel.class, "SparqlSoapEndPointDriverParametersPanel.urlTextField.text")); // NOI18N
                urlTextField.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                                urlTextFieldActionPerformed(evt);
                        }
                });

                javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
                this.setLayout(layout);
                layout.setHorizontalGroup(
                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(urlLabel)
                                .addGap(50, 50, 50)
                                .addComponent(urlTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
                                .addContainerGap())
                );
                layout.setVerticalGroup(
                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(urlTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(urlLabel))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                );

        }// </editor-fold>//GEN-END:initComponents

        private void urlTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_urlTextFieldActionPerformed
		driverParameters.setUrl( urlTextField.getText());
        }//GEN-LAST:event_urlTextFieldActionPerformed
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JLabel urlLabel;
        private javax.swing.JTextField urlTextField;
        // End of variables declaration//GEN-END:variables


	void reset() {
		String url = driverParameters.getUrl();
		urlTextField.setText(url);
	}

	public String getUrlValue() {
		return urlTextField.getText();
	}

	@Override
	public void update(Observable o, Object arg) {
		reset();
	}
}
